﻿using System.Linq;
using System.Web.Mvc;
using MVCLD.Helpers;
using MVCLD.Models;

namespace MVCLD.Controllers
{
    public class CategoryController : ApplicationController
    {
        #region Data Access
            MVCLDServiceModels db = new MVCLDServiceModels();
        #endregion

        // GET: /Category?category=something
        public ActionResult Index(int UrlID, int? p)
        {
            CategoryModels c = new CategoryModels();
            ViewData["CategoryName"] = db.GetCategoryName(UrlID);
            ViewData["GetSubCategories"] = db.GetSubCategories(UrlID);
            ViewData["CategoryDropDown"] = c.GetSubCategories(db.GetAllMainCategories().ToList());
            int pageSize = Settings.Settings.CategoryListingsPerPage.ToInt32();
            var Sites = db.GetLiveArticlesByCategoryUrlID(UrlID);
            var PagedArticles = new PaginatedList<Article>(Sites, p ?? 0, pageSize);
            return View(PagedArticles);
        }


    }
}
